import React from 'react'
import { View, Text, Image } from '@tarojs/components'
import './index.scss'
const Container = (props) => {
    const { data = {}, hasTitle, linkGo, children } = props
    const {
        backgroundType = 'default',
        paddingTop = 0,
        paddingLeft = 0,
        top = 0,
        bottom = 0,
        backgroundColor,
        backgroundImage,
        title,
        radiusType,
        borderRadius,
        showMore,
    } = data
    const renderBg = () => {
        if (backgroundType !== 'image') {
            return {
                background: backgroundColor
            }
        } else {
            return {
                ...backgroundObj(backgroundImage)
            }
        }
    }
    return <View style={{ borderRadius: radiusType === 'rightAngle' ? 'none' : borderRadius, padding: `${paddingTop}px ${paddingLeft}px`, marginTop: top + 'px', marginBottom: bottom + 'px', ...renderBg() }}>
        {hasTitle && <View onClick={(e) => {
            e.stopPropagation();
            linkGo && linkGo(data)
        }} className='MoreComponents_box'>
            <View className='design-preview-item-title'>
                <View className='MoreComponents_title'>{title}</View>
                {showMore && <View className='text-group'>查看更多{'>'}</View>}
            </View>

        </View>}
        {children}
    </View>
}
export default Container